<?php

# 下单和重新下单 请添加callbackUrl 订单状态回调函数
class uuController extends AppController
{

    /**
     * 下单
     * shop_no  门店编号
     * origin_id    第三方订单id
     * city_code    城市代码
     * cargo_price  订单金额
     * is_prepay    是否需要垫付 1:是 0:否 (垫付订单金额，非运费)
     * receiver_name    收货人姓名
     * receiver_address 收货人地址
     * receiver_lat 收货人地址维度（高德坐标系）
     * receiver_lng 收货人地址经度（高德坐标系）
     * callback 回调URL
     * receiver_phone 收货人手机号
     */
    public function send_parameterAction()
    {
        $dde = new UUExpressClass(TRUE,'ccba8bd4a2d54a2fb6df97e87979f303','2815a7a1f8e3405d81fd6263683ec4e7','910a0dfd12bb4bc0acec147bcb1ae246');
        $parameter = [
            'deliver_lng' => 121.42394,                                                         # 起始地坐标经度
            'deliver_lat' => 31.22024,                                                         # 起始地坐标纬度
            'city_name' => '上海市',                                                       # 订单所在城市名 称(如郑州市就填”郑州市“，必须带上“市”)
            'receiver_address' => '上海市奉贤宝龙广场',                                                  # 目的地址
            'shop_express_no' => '1235',                                                    # 第三方对接平台订单id
            'deliver_province' => '上海',                                                    # 第三方对接平台订单id
            'deliver_city' => '上海市',                                                    # 第三方对接平台订单id
            'deliver_area' => '长宁区',                                                    # 第三方对接平台订单id
            'deliver_address' => '淞虹路568号',                                                    # 第三方对接平台订单id
        ];
        $result = $dde->getorderprice($parameter);

        echo '<pre>';
        var_dump($result);
    }




    public function addorderAction()
    {
        $dde = new UUExpressClass(TRUE,'ccba8bd4a2d54a2fb6df97e87979f303','2815a7a1f8e3405d81fd6263683ec4e7','910a0dfd12bb4bc0acec147bcb1ae246');
        $parameter = [
            'price_token' => 'f521d41bd086424faf00fa16b29966a8',
            'total_money' => "69.00",                                                                  # 订单金额，计算订单价格接口返回的total_money
            'balance_paymoney' => "69.00",                                                        # 实际余额支付金额计算订单价格接口返回的need_paymoney
            'receiver' => 'ami',
            'receiver_tel' => 17321295203,
            'shop_express_remark' => '没啥好说的',
            'callbackUrl' =>  'GetUUCallBack',                      # 订单提交成功后及状态变化的回调地址 20200616 需新增
            'push_type' =>  2,                                                              # 推送方式（0 开放订单，2测试订单）默认传0即可
            'special_type' =>  0,                                                           # 特殊处理类型，是否需要保温箱 1需要 0不需要
            'callme_withtake' =>  0,                                                                                # 取件是否给我打电话 1需要 0不需要
            'deliver_phone' =>  17321295203,                                                             # 发件人电话，（如果为空则是用户注册的手机号）
            'pay_type' =>  1,                                                                  # 支付方式：1=企业支付 0账户余额支付（企业余额不足自动转账户余额支付）
        ];
        $result = $dde->addorder($parameter);
        echo '<pre>';
        var_dump($result);
    }




    public function cancelorderAction()
    {
        $dde = new UUExpressClass(TRUE,'ccba8bd4a2d54a2fb6df97e87979f303','2815a7a1f8e3405d81fd6263683ec4e7','910a0dfd12bb4bc0acec147bcb1ae246');
        $parameter = [
            'order_code' => 'U2500800201113110110739062',
            'reason' => "69.00",
        ];
        $result = $dde->cancelorder($parameter);
        echo '<pre>';
        var_dump($result);
    }



    public function payonlinefeeAction()
    {
        $dde = new UUExpressClass(TRUE,'ccba8bd4a2d54a2fb6df97e87979f303','2815a7a1f8e3405d81fd6263683ec4e7','910a0dfd12bb4bc0acec147bcb1ae246');
        $parameter = [
            'order_code' => 'U2500800201119141618396062',
            'origin_id' => '100046_ELM5009901442889075751_265',
            'onlinefee' => 2,
        ];
        $result = $dde->payonlinefee($parameter);
        echo '<pre>';
        var_dump($result);
    }



    public function getshoplistAction()
    {
        $dde = new UUExpressClass(TRUE,'ccba8bd4a2d54a2fb6df97e87979f303','2815a7a1f8e3405d81fd6263683ec4e7','910a0dfd12bb4bc0acec147bcb1ae246');
        $result = $dde->getshoplist();
        echo '<pre>';
        var_dump($result);
    }


}
